package com.example.question.array;

public class Code08_27 {
    public static void main(String[] args) {
        Code08_27 code = new Code08_27();
        int[] nums = new int[]{0, 1, 2, 2, 3, 0, 4, 2};
        int val = 2;
        int removed = code.removeElement(nums, val);
        System.out.println(removed);
    }



    public int removeElement(int[] nums, int val) {
        int i = 0;
        for (int num : nums) {
            if (num != val) {
                nums[i++] = num;
            }
        }
        return i;
    }
}
